package com.gagakuai.demo.registrytest;

import com.gagakuai.demo.beanFactoryPostProccess.CompoentConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;

/*
 * @program: settement
 * @description:
 * @author: houhong
 * @create: 2022-11-12 23:31
 */
public class RegisMainConfigTest {


    public static void main(String[] args) throws Exception {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);

       /* context.scan("com.gagakuai.demo.registrytest");
        context.refresh();*/
        // context.addBeanFactoryPostProcessor(new TestBeanDefinitionRegistryPostProcessor());

        ServiceContext contextBean = context.getBean(ServiceContext.class);
        AbstractService instance = contextBean.getInstance("3");
        instance.sayHelloHandler();;

        String[] definitionNames = context.getBeanDefinitionNames();

        for (String definitionName : definitionNames) {
            System.out.println(String.format("%s->%s", definitionName, context.getBean(definitionName)));
        }
    }
}